package com.pactera.common;

import com.pactera.config.PacteraLoader;
import com.pactera.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created by 17894 on 2021/3/12.
 */
@Service
public class CommonService {

    @Autowired
    private PacteraLoader loader;

    public List<Map<String, Object>> defaultCities() throws Exception {
        List<Map<String, Object>> resultList = new ArrayList<>();
        Properties properties = loader.getProperties();
        Enumeration enus = properties.propertyNames();
        while (enus.hasMoreElements()) {
            String enumKey = (String) enus.nextElement();
            Map map = JsonUtil.parseJsonStringToMap(properties.getProperty(enumKey));
            resultList.add(map);
        }
        return resultList;
    }

}
